<template>
  <switch
    @change="switchChange"
    :checked="modelValue"
    :style="style"
    :disabled="disabled"
    :color="color"
  ></switch>
</template>

<script setup lang="ts">
// 基于uni原生switch的封装,已用v-model抛出
// switch的大小需要使用style去控制

const { modelValue, style, color, disabled } = defineProps<{
  modelValue: boolean
  style?: AnyObject
  disabled?: boolean
  color?: string
}>()

const emit = defineEmits<{ (e: 'update:modelValue', value: boolean): void }>()
const switchChange = (e: any) => {
  emit('update:modelValue', e.detail.value)
}
</script>

<style lang="scss" scoped></style>
